package ray.math;

public class Ray {
	
	public Point3 origin = new Point3();
	public Vector3 direction = new Vector3();
	
	public Ray(){
		
	}
	
	public void setOrigin(Point3 origin){
		this.origin = origin;
	}
	
	public void setDirection(Vector3 direction){
		this.direction = direction;
	}
	
	//Calculates a ray given two points and stores
	//the resultant origin point and direction
	//vector in this Ray
	public void calc(Point3 e,Point3 s){
		
		origin = new Point3(e.x,e.y,e.z);
		
		direction.sub(s,origin);
		direction.normalize();
		
	}
	
	public Point3 calcPoint(double t){
		Point3 point = new Point3(origin.x,origin.y,origin.z);
		
		Vector3 tempVector = new Vector3();
		tempVector.scaleAdd(t, direction);
		
		point.add(tempVector);
		
		return point;
	}

}
